<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>如何通过 Vdom 实现一个类似于ol/li这样得列表UI?</title>
  <script src="https://unpkg.com/vue@next"></script>
  <style>
    .mt-4 {
      margin: 10px;
    }
  </style>
</head>

<body>
  参考： https://www.cnblogs.com/guangzan/p/13358322.html<br />
  如何通过 Vdom 实现一个类似于ol/li这样得列表UI?<br />
  attrs 与 props 得区别
  <div id="app"></div>

  <script>
    const { h, createApp } = Vue;

    const Stack = {
      render() {
        const slot = this.$slots.default ? this.$slots.default() : [];
        return h(
          'div',
          { class: 'stack' },
          slot.map(child => {
            console.log(this.$props);
            return h("div", { class: `mt-${this.$attrs.size}` }, [child]);
          })
        );

      },
    };

    const App = {
      components: {
        Stack
      },
      template: `
      <Stack size="4">
          <div>hello</div>
          <Stack size="4">
              <div>hello</div>
              <div>hello</div>
          </Stack>
      </Stack>
      `
    }

    createApp(App).mount('#app');

  </script>
</body>

</html>
